<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>修改角色信息</title>
</head>
<body bgcolor="#ADD8E6" >
	<center><h2>角色修改</h2></center>
<div style="margin-left:30%;margin-top:10% ;font-size:15px;" >

     <c:forEach items="${roleList }" var="role" varStatus="v">
     
    <form action="<%=request.getContextPath() %>/role/RoleServlet?command=update&id=${role.id }" method="post" onsubmit="return validates();">
                         角色名称:<input type="text" name="name" value="${role.name }" placeholder="名称" id="name" onblur="upperCase(this ,${role.id })"/><span id="nameInfo"></span><br><br>
                             状　　态:
              <c:set var="state" value="${role.state }"></c:set>  
	          <c:if test="${state == 1}">
	            <input type="radio" name="state" value="1" checked="checked" />启用<input type="radio" name="state" value="2"/>禁止<span id="stateInfo"></span> <br><br>
	          </c:if>
	          <c:if test="${state == 2}">
	            <input type="radio" name="state" value="1"/>启用<input type="radio" name="state" value="2" checked="checked" />禁止<span id="stateInfo"></span> <br><br>
	          </c:if>  
                             
                             备　　注:<input type="text" name="memo" value="${role.memo }" placeholder="备注" id="memo"/><span id="memoInfo"></span> <br><br><br>
　　　    <input type="submit" value="修改" onclick="return confirm('是否修改？');">
      </form>
	</c:forEach>
<script type="text/javascript">
	    function upperCase(name, id)
      {
        	
       	var xmlhttp;
        var roleName = document.getElementById("name").value;
        var id = id;
        
       	if (window.XMLHttpRequest)
       	  {// code for IE7+, Firefox, Chrome, Opera, Safari
       	  xmlhttp=new XMLHttpRequest();
       	  }
      	else
       	  {// code for IE6, IE5
       	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
       	  }
       	xmlhttp.onreadystatechange=function()
       	  {
       	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
       	    {
       		var print = xmlhttp.responseText
       	    document.getElementById("nameInfo").innerHTML=print;
       	    }
       	  }
       	  
       	xmlhttp.open("post","<%=request.getContextPath()%>/role/RoleServlet?command=onlyRoleName&name="+roleName+"&id=" +id,true);
       	xmlhttp.send();
     } 
</script>
<script src="<%=request.getContextPath() %>/static/sys/class-manager/js/class_update.js"></script>
</div>
</body>
</html>